feat: telegram use parse mode ModeMarkdownV2 instead of ModeHTML#1018
feat: telegram use parse mode ModeMarkdownV2 instead of ModeHTML#1018alexhoshina merged 16 commits intosipeed:mainfrom
Conversation
|
@alexhoshina Hi, could you look at my PR? |
|
Thanks for the reminder and for your patience.
Thanks again for your understanding and collaboration! |
|
|
Hey @alexhoshina, thanks for flagging this — it's a good discussion to have before we go in two different directions! After looking at both PRs, I'd lean toward sticking with HTML. Here's my thinking: LLM output is messy by nature The community generally says the same thing A few concerns with the MarkdownV2 parser here The formatting issues are fixable under HTML All that said — I really appreciate the work in this PR, @Alexandersfg4! The heading-to-bold conversion is a nice touch and something we could totally bring over to the HTML path too. Curious what you both think! |
Hi, thank you for the feedback! I appreciate the thorough review.
{
"channels": {
"telegram": {
"enabled": true,
"token": "YOUR_BOT_TOKEN",
"allow_from": ["YOUR_USER_ID"],
"use_markdown_v2": true
}
}
}
Let me know if that sounds like a good middle ground! |
I think this is feasible |
Hi, I pushed changes with flag use_markdown_v2 |
|
Hi, we merged #935 yesterday, so you might need to resolve the conflicts |
@alexhoshina Hi, I resolved the conflicts Also tested the new feature (when use_markdown_v2=false/true):
|
|
Sorry! I was a bit late in reviewing. Could you please resolve the conflicts again? Thank you very much. |
Hi, I resolved again the conflicts. @alexhoshina kind tag you, thank you very much! |
|
|
I fixed the linter and fixed MC :) Kind ping @alexhoshina |
pkg/channels/telegram/telegram.go
Outdated
| } | ||
|
|
||
| if err := c.sendHTMLChunk(ctx, chatID, threadID, htmlContent, chunk, replyToID); err != nil { | ||
| if err := c.sendChunk(ctx, chatID, threadID, content, chunk, replyToID, useMarkdownV2); err != nil { |
There was a problem hiding this comment.
The parameter order was passed incorrectly
- The chunk was passed into the replyToID parameter
- The actual replyToID was passed into the mdFallback parameter
There was a problem hiding this comment.
Sorry, I was a sick
FIxed the bug
pkg/channels/telegram/telegram.go
Outdated
| parsedContent := parseContent(content, useMarkdownV2) | ||
| editMsg := tu.EditMessageText(tu.ID(cid), mid, parsedContent). | ||
| WithParseMode(telego.ModeMarkdownV2) |
There was a problem hiding this comment.
The current edit request enforces the use of MarkdownV2 parsing mode. When v2 is not enabled, message edits will either fail to parse or fall back
|
@alexhoshina Hi, sorry for the delay. I was out sick, but I've fixed the issues now. Could you please take another look at my PR? |
|
Thank you for your contribution! |
…eed#1018) * feat: telegram use parse mode ModeMarkdownV2 instead of ModeHTML * handle expandable block quotation starts, add test for all md2 formats * fix: linter issue * feat: added flag use_markdown_v2, corrected config, updated documentation * move parseChatID to parser_markdown_to_html * fix: tests and linter issues * fix: case with ~ * test: fixed Test_markdownToTelegramMarkdownV2 * fix: regex block-quote line > * fix: linter issues * fix: send chunk param mismatched, in edit msg use HTML parse mode too * fix: remove from .gitignore redundant comment
|
@Alexandersfg4 Nice improvement switching Telegram to MarkdownV2 parsing! The old HTML mode had quite a few formatting quirks, so this is a welcome change. We are building a PicoClaw Dev Group on Discord where contributors can connect and collaborate more directly. If you are interested, send an email to |


📝 Description
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
Currently, Picoclaw sends messages from the agent to Telegram in the following way:


Input in MD format -> Parsed into HTML -> Sent as a message.
If the message fails to send, a fallback message is sent with HTML format and an empty parse mode.
In current implementation I often observe something like this (heading tags, HTML tags
and etc.):
My proposal:
Input in MD format -> Parsed into Telegram MD2 format -> Sent as a message. (less bugs could be handled)
If the message fails to send, a fallback message is sent with MD format and an empty parse mode.
Heading is not supporting so we transform heading -> bolding.
Unit tests created for the feature.
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
☑️ Checklist